-
Notifications
You must be signed in to change notification settings - Fork 450
Ignore visibility method, attr definition, module_function within block #1595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3231430 to
de00323
Compare
|
🚀 Preview deployment available at: https://a550c35f.rdoc-6cd.pages.dev (commit: 96f88d1) |
| end | ||
|
|
||
| def _visit_call_alias_method(call_node) | ||
| return if @scanner.in_proc_block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the same check be added to visit_alias_method_node too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Fixed
lib/rdoc/parser/prism_ruby.rb
Outdated
| end | ||
|
|
||
| def _visit_call_public_private_class_method(call_node, visibility) | ||
| yield |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly, related, but why does this method call yield here but _visit_call_public_private_protected calls it in a branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No specific reason. I think it's better to make it align.
If we're not calling yield (block is { super }) conditionally, calling super before calling this method is better.
I added this change:
_visit_call_public_private_class_method(args) { super }
def _visit_call_public_private_class_method(call_node, visibility)
yield
...
end
# ↓
super
_visit_call_public_private_class_method(args)
def _visit_call_public_private_class_method(call_node, visibility)
...
endWe need to ignore these within `Module.new do end` and any other block because it might be a metaprogramming block.
de00323 to
96f88d1
Compare
| @in_proc_block = true | ||
| yield | ||
| @in_proc_block = false | ||
| @in_proc_block = in_proc_block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tap do
include A # in_proc_block = true
tap do end # Exiting this block was making `@in_proc_block = false
include B # in_proc_block was false, fixed to true
end
We need to ignore these within
Module.new do endand any other block because it might be a metaprogramming block.Ignoring
defincludeextendin a block is already implemented. This pull request also make RDoc ignore visibility methods, attr definition and module_function in a block.Found while generating document in rails/rails
https://github.com/rails/rails/blob/45ee3bf84f20af55b8619b5dcc22a5e22a4ac0e7/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb#L307